package com.guozinhs.auto.frame;

import javax.swing.*;
import java.awt.*;
import java.util.Objects;

/**
 * 带背景图的JPanel
 *
 * @Author: GuoZi
 * @Date: 2022/2/11 14:36
 */
public class ImagePanel extends JPanel {

    private Image image;

    public void setImage(Image image) {
        this.image = image;
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (Objects.nonNull(image)) {
            g.drawImage(image, 0, 0, this.getWidth(), this.getHeight(), this);
        }
    }

}
